﻿using System;

using DreamCube.Foundation.Basic.Utility;

namespace DreamCube.TaobaoGJ.BLL
{
    /// <summary>
    /// 商品的帮助类
    /// </summary>
    public static class GoodHelper
    {   
        /// <summary>
        /// 因为淘宝的商品标题最大为30个字符，所有要格式化一下
        /// </summary>
        /// <param name="title"></param>
        /// <returns></returns>
        public static String FormatGoodTitle(String title, ShopType type = ShopType.Taobao)
        {
            Int32 length = 0;
            if (type == ShopType.Taobao)
            {
                length = Int32.Parse(Properties.Resources.TB_GoodTitleMaxLength);
            }
            else if (type == ShopType.Paipai)
            {
                length = Int32.Parse(Properties.Resources.PP_GoodTitleMaxLength);
            }
            if (title.Length > length)
            {
                return title.Substring(0, length);
            }
            return title;
        }
    }
}

